package net.lijingye.education.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import net.lijingye.education.entity.Assignment;
import net.lijingye.education.entity.StudentAssignment;
import net.lijingye.education.util.CommonUtil;

import java.util.Date;

/**
 * Created by LijingYe on 2016/3/26.
 */
public class AssignmentLiteVO {
    @JSONField(name = "id", ordinal = 0, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String id;
    @JSONField(name = "lesson", ordinal = 1, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String lesson;
    @JSONField(name = "title", ordinal = 1, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String title;
    @JSONField(name = "time", ordinal = 2, serialzeFeatures = SerializerFeature.WriteMapNullValue, format = "yyyy/MM/dd HH:mm")
    private Date time;
    @JSONField(name = "endTime", ordinal = 3, serialzeFeatures = SerializerFeature.WriteMapNullValue, format = "yyyy/MM/dd")
    private Date endTime;
    @JSONField(name = "status", ordinal = 4, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String status;
    @JSONField(name = "brief", ordinal = 5, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String brief;

    public AssignmentLiteVO(Assignment assignment, StudentAssignment studentAssignment) {
        this.id = assignment.getId();
        this.lesson = assignment.getLesson().getCourse().getName();
        this.title = assignment.getTitle();
        this.time = assignment.getTime();
        this.endTime = assignment.getEndTime();
        this.brief = CommonUtil.getBriefText(assignment.getContent());
        if (assignment.isNeedSubmit()) {
            if (null == studentAssignment) {
                this.status = "未提交";
            } else {
                this.status = "已提交";
            }
        } else {
            this.status = "无需提交";
        }
    }

    public AssignmentLiteVO(String id, String lesson, String title, Date time, Date endTime, String status, String brief) {
        this.id = id;
        this.lesson = lesson;
        this.title = title;
        this.time = time;
        this.endTime = endTime;
        this.status = status;
        this.brief = brief;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getLesson() {
        return lesson;
    }

    public void setLesson(String lesson) {
        this.lesson = lesson;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getBrief() {
        return brief;
    }

    public void setBrief(String brief) {
        this.brief = brief;
    }

    @Override
    public String toString() {
        return "AssignmentLiteVO{" +
                "id='" + id + '\'' +
                ", lesson='" + lesson + '\'' +
                ", title='" + title + '\'' +
                ", time=" + time +
                ", endTime=" + endTime +
                ", status='" + status + '\'' +
                ", brief='" + brief + '\'' +
                '}';
    }
}
